﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace LiveCharts.Wpf.Geometries
{
	public class Circle : GeometryShape
	{
		public override void Draw(PathGeometry path, Point location, bool animate, TimeSpan animationsSpeed)
		{
			this.method_0(path, location, animate, animationsSpeed);
		}

		public override void Erase(PathGeometry path)
		{
			path.Figures.Remove(this.pathFigure_0);
		}

		private void method_0(PathGeometry pathGeometry_0, Point point_0, bool bool_0, TimeSpan timeSpan_0)
		{
			if (this.pathFigure_0 == null)
			{
				this.method_1(pathGeometry_0);
			}
			double num = base.Diameter / 2.0;
			if (bool_0)
			{
				this.pathFigure_0.BeginAnimation(PathFigure.StartPointProperty, new PointAnimation(new Point(point_0.X - num, point_0.Y), timeSpan_0));
				this.arcSegment_0.BeginAnimation(ArcSegment.PointProperty, new PointAnimation(new Point(point_0.X + num, point_0.Y), timeSpan_0));
				this.arcSegment_0.BeginAnimation(ArcSegment.SizeProperty, new SizeAnimation(new Size(num, num), timeSpan_0));
				this.arcSegment_1.BeginAnimation(ArcSegment.PointProperty, new PointAnimation(new Point(point_0.X - num, point_0.Y), timeSpan_0));
				this.arcSegment_1.BeginAnimation(ArcSegment.SizeProperty, new SizeAnimation(new Size(num, num), timeSpan_0));
				return;
			}
			this.pathFigure_0.StartPoint = new Point(point_0.X - num, point_0.Y);
			this.arcSegment_0.Point = new Point(point_0.X + num, point_0.Y);
			this.arcSegment_0.Size = new Size(num, num);
			this.arcSegment_1.Point = new Point(point_0.X - num, point_0.Y);
			this.arcSegment_1.Size = new Size(num, num);
		}

		private void method_1(PathGeometry pathGeometry_0)
		{
			this.arcSegment_0 = new ArcSegment();
			this.arcSegment_1 = new ArcSegment();
			this.pathFigure_0 = new PathFigure
			{
				Segments = new PathSegmentCollection(2)
				{
					this.arcSegment_0,
					this.arcSegment_1
				}
			};
			pathGeometry_0.Figures.Add(this.pathFigure_0);
		}

		private PathFigure pathFigure_0;

		private ArcSegment arcSegment_0;

		private ArcSegment arcSegment_1;
	}
}
